package com.qf.config;

import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.Queue;
import org.springframework.amqp.core.TopicExchange;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class RabbitMQConfig {

    @Value("${es.esQueueName}")
    private String esQueueName;

    @Value("${es.esExchangeName}")
    private String esExchangeName;

    @Value("${es.esRouting}")
    private String esRouting;

    @Bean
    public TopicExchange esExchange(){
        return new TopicExchange(esExchangeName,true,false);
    }

    @Bean
    public Queue esQueue(){
        return new Queue(esQueueName,true,false,false);
    }

    @Bean
    public Binding emailQueueBindingExchange() {
        return BindingBuilder.bind(esQueue()).to(esExchange()).with(esRouting);
    }
}
